<template>
	<view>
		<u-toast ref="uToast"></u-toast>
		<u-action-sheet :actions="actions" @close="selectCategoryClose" @select="selectCategoryClick" :closeOnClickOverlay="true" :closeOnClickAction="true"  :title="title" :show="show"></u-action-sheet>
	</view>
</template>

<script>
	export default {
		name:"goshop-report",
		props: {
		  postId:{
				type:Number,
				default:0
		  },
		  show:{
				type:Boolean,
				default:false
		  }
		},
		data() {
			return {
				title:this.$t('report.type.text'),
				actions: [
					{
						name:this.$t('report.advertise.text'),
						categoryId:1
					},
					{
						name: this.$t('report.pornography.text'),
						categoryId:2
					},
					{
						name: this.$t('report.defamation.text'),
						categoryId:3
					},
					{
						name: this.$t('report.reactionary.text'),
						categoryId:4
					},
					{
						name: this.$t('report.fake.text'),
						categoryId:5
					},
					{
						name: this.$t('report.other.text'),
						categoryId:6
					}
				],
				form:{
					categoryId:'',
					content:'',
				}
			};
		},
		methods:{
			selectCategoryClick(index){
				let that = this;
				this.form.content = '帖子ID：' + this.postId;
				this.form.categoryId = index.categoryId;
				createReport(this.form).then(res => {
					if (res.code === 0) {
						this.$refs.uToast.show({
							message: that.$t('report.feebsuccess.text'),
							type: 'success'
						})
						uni.hideLoading();
					} else {
						uni.hideLoading();
						uni.showModal({
							showCancel: false,
							title: that.$t('report.feebfailed.text'),
							content: res.msg,
						});
					}
				});
			},
			selectCategoryClose(){
			    this.show = false;
			},
		}
	}
</script>

<style lang="scss">

</style>